<?php

class authenticationActions extends sfActions {

    public function executeRegister(sfWebRequest $request){
        if(!$this->getUser()->isAuthenticated()){
            $this->getUser()->setAuthenticated(true);
            $this->redirect('@dashboard');
        }
    }

    public function executeLogin(sfWebRequest $request){
        if(!$this->getUser()->isAuthenticated()){
            $this->getUser()->setAuthenticated(true);
            $this->redirect('@homepage');
        }
    }

    public function executeLogout(sfWebRequest $request){
        $this->getUser()->setAuthenticated(false);
        $this->redirect('@homepage');
    }

    public function executeChangeLang(sfWebRequest $request){
        $lang = $request->getParameter('lang');
        $this->getUser()->setCulture($lang);
        $this->redirect('@homepage');
    }

}